﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using HigLabo.Net;

namespace HigLabo.WindowsAzure.RestService.ServiceManagement
{
    public class UpdateAffinityGroupCommand : ManagementServiceCommand<UpdateAffinityGroupResult>
    {
        /// <summary>
        /// AffinityGroup名
        /// </summary>
        public String AffinityGroupName { get; private set; }

        /// <summary>
        /// リクエストのボディ
        /// </summary>
        public UpdateAffinityGroup RequestBody { get; private set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="affinityGroupName"></param>
        /// <param name="requestBody"></param>
        public UpdateAffinityGroupCommand(String affinityGroupName, UpdateAffinityGroup requestBody)
        {
            if (String.IsNullOrEmpty(affinityGroupName))
            {
                throw new ArgumentException("affinityGroupName must not be null", "affinityGroupName");
            }
            if (requestBody == null)
            {
                throw new ArgumentNullException("requestBody");
            }
            this.AffinityGroupName = affinityGroupName;
            this.RequestBody = requestBody;
        }

        public override string GetRequestUri()
        {
            return String.Format("affinitygroups/{0}", this.AffinityGroupName);
        }

        public override HttpMethodName MethodName
        {
            get { return HttpMethodName.Put; }
        }

        public override string ContentType
        {
            get { return "application/xml"; }
        }

        public override Dictionary<String, String> GetRequestHeaders()
        {
            return null;
        }

        public override System.IO.Stream GetRequestBodyStream()
        {
            return this.GetStream(this.RequestBody.CreateText());
        }

    }
}
